#include "SFML\Graphics.hpp"

#include "AnimationHandlerFactory.h"

AnimationHandlerFactory::~AnimationHandlerFactory()
{
	 for (std::map<handler_name,AnimationHandler*>::iterator it=_animationHandlers.begin(); it!=_animationHandlers.end(); ++it)
		 delete it->second;
}

AnimationHandler* AnimationHandlerFactory::getAnimationHandler(handler_name h)
{
	if( _animationHandlers[h]==NULL)
	{
		sf::Texture* texture= new sf::Texture();
		switch (h)
		{
			case avatar: texture->loadFromFile("player.png"); break;
			case ennemy: texture->loadFromFile("mudling.png"); break;
		}
		_animationHandlers[h]=new AnimationHandler(texture);
	}
	
	return _animationHandlers[h];
}
